package com.yc.cloud.openai.portal.controller;

import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import com.yc.cloud.common.basic.api.ResponseResult;
import com.yc.cloud.openai.portal.dto.PromptDto;
import com.yc.cloud.openai.portal.dto.request.ImageToModelRequest;
import com.yc.cloud.openai.portal.dto.request.TextToModelRequest;
import com.yc.cloud.openai.portal.service.ModelService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.val;
import lombok.extern.slf4j.Slf4j;

/**
 * AIGC/3D模块
 */
@RestController
@RequestMapping("model")
@Api(value = "3D模块", tags = "3D模块")
@Slf4j
public class ModelController {
    private final ModelService modelService;

    public ModelController(ModelService modelService) {
        this.modelService = modelService;
    }

    @PostMapping("/image-to-model")
    @ApiOperation(value = "图片转3D模型", notes = "用户输入图片，后台将图片转换为3D模型")
    public ResponseResult<PromptDto> imageToModel(@Validated ImageToModelRequest param, MultipartFile file) {
        val result = modelService.imageToModel(param, file);
        return result != null ? ResponseResult.success(result) : ResponseResult.failed("图片转3D模型失败");
    }

    @PostMapping("/text-to-model")
    @ApiOperation(value = "文本转3D模型", notes = "用户输入文本，后台将文本转换为3D模型")
    public ResponseResult<PromptDto> textToModel(@RequestBody TextToModelRequest request) {
        val result = modelService.textToModel(request);
        return result != null ? ResponseResult.success(result) : ResponseResult.failed("文本转3D模型失败");
    }

    // @GetMapping("/test")
    // @ApiOperation(value = "测试", notes = "测试")
    // public ResponseResult<String> test() {
    //     return ResponseResult.success("测试成功");
    // }

}
